/*
 * Copyright (c)$today.year.month.day
 *  admin:郑程荣.
 *  文件名:CheckPointActivity.java
 *  项目功能:
 */

/*
 * Copyright (c)$today.year.month.day
 *  admin:郑程荣.
 *  文件名:WarnInfoActivity.java
 *  项目功能:
 */


package com.jg.myproject.module.checkpoint;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.allen.library.SuperTextView;
import com.bumptech.glide.Glide;
import com.jg.myproject.api.Const;
import com.jg.myproject.api.bean.BaseEntity;
import com.jg.myproject.api.bean.CommonRequestBean;
import com.jg.myproject.api.bean.reponse.CommonReponseBean;
import com.jg.myproject.module.base.BaseActivity;
import com.jg.myproject.presenter.CheckPointPresenter;
import com.jg.myproject.pview.ICommonView;
import com.jg.myproject.utils.RxSPTool;
import com.jg.myproject.utils.SPUtils;
import com.zcr.myproject.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import uk.co.senab.photoview.PhotoView;

/**
 * Created by llz on 2018/11/19.
 */
public class CheckPointActivity extends BaseActivity implements ICommonView {
    @BindView(R.id.stv_01)
    SuperTextView mStv01;
    @BindView(R.id.stv_02)
    SuperTextView mStv02;
    @BindView(R.id.stv_03)
    SuperTextView mStv03;
    CheckPointPresenter mPresenter;
    @BindView(R.id.tv_01)
    TextView mTv01;
    @BindView(R.id.tv_02)
    TextView mTv02;
    @BindView(R.id.tv_03)
    TextView mTv03;
    @BindView(R.id.tv_04)
    TextView mTv04;
    @BindView(R.id.photoView)
    ImageView mPhotoView;
    String url;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_check_point;
    }

    @Override
    protected void initViews() {
        initTitle(true, "测点分布");
        mPresenter = new CheckPointPresenter(this);
        mStv01.setCenterString(RxSPTool.getString(this, Const.PROJECTNAME));
        mStv02.setCenterString(RxSPTool.getString(this, Const.MONITORPARTCODE));
        mStv03.setCenterString(RxSPTool.getString(this, Const.MONITORPARTNAME));

        CommonRequestBean commonRequestBean = new CommonRequestBean(); // 3.1组织请求的数据
        String id = RxSPTool.getString(this, Const.PROJECTID);
        String monitorPartId = RxSPTool.getString(this, Const.MONITORPARTID);
        String monitorPartCode = RxSPTool.getString(this, Const.MONITORPARTCODE);
        commonRequestBean.setGcId(id);
        commonRequestBean.setMonitorPartId(monitorPartId);
        commonRequestBean.setMonitorPartCode(monitorPartCode);
        String userId = RxSPTool.getString(CheckPointActivity.this, Const.USERID);
        commonRequestBean.setUserId(userId);
        mPresenter.getData(commonRequestBean);
        mPhotoView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle =new Bundle();
                bundle.putString(Const.IMAGEURL,url);
                toNextActivityAndParamsAnim(CheckPointPicActivity.class,bundle);
            }
        });
    }

    @Override
    protected void updateViews(boolean isRefresh) {
    }
    @Override
    public void getReponseBeans(BaseEntity<CommonReponseBean> bean) {
        if (bean != null && bean.getBeans() != null) {
            CommonReponseBean.CommonReponseChildBean commonReponseChildBean = bean.getBeans().get(0).getItemBean().get(0);
            mTv01.setText(commonReponseChildBean.getHorzDsplNum());
            mTv02.setText(commonReponseChildBean.getTmplStlNum());
            mTv03.setText(commonReponseChildBean.getPressureNum());
            mTv04.setText(commonReponseChildBean.getTiltNum());
            if (bean.getBeans().get(0).getFileList() != null && bean.getBeans().get(0).getFileList().size() > 0) {
                CommonReponseBean.CommonReponseChildBean commonReponseChildBean1 = bean.getBeans().get(0).getFileList().get(0);
                 url = "http://120.77.59.176:8030/fileUploadMongoDB/getMongodbFile?relatedId=" + commonReponseChildBean1.getRelateId() + "&typeId=" + commonReponseChildBean1.getTypeId() + "&tarFileName=" + commonReponseChildBean1.getTarFileName() + "";
                Glide.with(this)
                        .load(url)
                        .into(mPhotoView);
            }
        }
    }
}
